"""
5.框架切换.py
页面中包含了iframe 或者 frame 的 标签, 这个标签是一个页面的容器. 实现页面嵌套页面的功能.
selenium只能在当前页面工作,如果页面元素不在当前页面,则无法定位.
切入:
    switch_to.frame(id 或者是 name)
    switch_to.parent_frame()   返回上一届框架
    switch_to.default_content()  返回最外层  根框架
html
    html1
        html2
            element1   switch逐层切入
        html3
            element2
        element3
    element4
"""
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
# driver.minimize_window()
sleep(2)
driver.maximize_window()
sleep(2)
def login():
    driver.get("http://localhost/ranzhi/www/")
    sleep(2)
    t = driver.find_element(By.ID,"account")
    # #动作链表示可以连续执行的动作,每个动作用 '.'进行连接,最后使用perform()进行结尾
    t.send_keys("admin")
    sleep(2)
    driver.find_element(By.ID,"password").send_keys("123456")
    sleep(2)
    driver.find_element(By.ID,"submit").click()
    sleep(5)
    driver.find_element(By.XPATH,"/html/body/div[1]/div[1]/div/ul[1]/li[8]/button/i").click()
    sleep(2)
    driver.switch_to.frame("iframe-superadmin")
    driver.find_element(By.CSS_SELECTOR,"html.screen-desktop-wide.device-desktop body.m-admin-index div.row.page-content.with-menu div#shortcutBox.container div.row div.col-md-4.col-sm-6 div.shortcut.user a h3").click()
    sleep(2)
    driver.switch_to.default_content()
    driver.find_element(By.LINK_TEXT,"签退").click()
    sleep(3)
    driver.quit()

# def add_member():
#     driver